//对应 pipe
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#define size 100
int main(void)
{
int filedes[2], line;
pid_t pid;
char message[size];
if(pipe(filedes)==-1) //创建管道
{
perror("creat pipe failed!");
return 1;
}
else if((pid=fork())<0)
{
perror("creat child process failed!");
return 1;
}
else if(pid==0)
{
close(filedes[0]);
printf("THIS IS CHILD PROCESS WRITE MESSAGE!\n");
write(filedes[1],"Welcome to openSuSE !",22);/*这儿可以这样写
***************************************************************
char s[]="Welcome to openSuSE !";
write(filedes[1],s,22);  意思就是将s[]的前22个字符写进filedes[1]中*/
}
else
{
close(filedes[1]);
printf("THIS IS PARENT PROCESS READ THE MESSAGE SEND BY CHILD PROCESS!\n");
line=read(filedes[0],message,size);
write(STDOUT_FILENO,message,line);
printf("\n");
wait(NULL);
_exit(0);
}
return 0;
}


